package com.controller;


import com.fz.entity.Student;
import com.fz.mapper.StudentMapper;
import com.fz.mybatis.DbHelper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;


/**
 * Created by bai on 2017/6/23.
 */

public class TestController implements Controller{
    @Override
    public ModelAndView handleRequest(HttpServletRequest req, HttpServletResponse resp) throws Exception {
       resp.setCharacterEncoding("utf-8");
       resp.setContentType("text/html;charset=utf8");
        ModelAndView mv = new ModelAndView("show");
        SqlSession session = new DbHelper().getSession();
        StudentMapper stu = session.getMapper(StudentMapper.class);
        List<Student> list = stu.query();
        mv.addObject("student",list);

        return mv;
    }
}
